﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VirtualPress.Infrastructure.Entities.Repository;
using VirtualPress.Infrastructure.Entities.Enum;

namespace VirtualPress.Infrastructure.Entities.Entity
{
    public class ArticleHistory : IAccessible<T_ArticleHistory, ArticleHistory>, ILogicEntity<T_ArticleHistory, ArticleHistory>
    {
        #region Fileds
        public int Id { get; set; }

        public int ManuscriptId { get; set; }

        /// <summary>
        /// 上一状态
        /// </summary>
        public ArticleStatus PreStatus { get; set; }

        /// <summary>
        /// 当前状态
        /// </summary>
        public ArticleStatus CurrentStatus { get; set; }

        public string Message { get; set; }

        /// <summary>
        /// 支付交易号
        /// </summary>
        public string Txid { get; set; }

        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 操作员
        /// </summary>
        public string Operator { get; set; }
        #endregion

        protected override void Covariant(T_ArticleHistory model)
        {
            if (model != null)
            {
                this.CreateTime = model.CreateTime;
                this.CurrentStatus = (ArticleStatus)model.CurrentStatus;
                this.Id = model.Id;
                this.ManuscriptId = model.ManuscriptId;
                this.Message = model.Message;
                this.Operator = model.Operator;
                this.PreStatus = (ArticleStatus)model.PreStatus;
                this.Txid = model.Txid;
            }
        }

        protected override T_ArticleHistory Inverter(ArticleHistory model)
        {
            if (model != null)
            {
                return new T_ArticleHistory()
                {
                    CreateTime = model.CreateTime,
                    CurrentStatus = (int)model.CurrentStatus,
                    Id = model.Id,
                    ManuscriptId = model.ManuscriptId,
                    Message = model.Message,
                    Operator = model.Operator,
                    PreStatus = (int)model.PreStatus,
                    Txid = model.Txid,
                };
            }
            return null;
        }

        public ArticleHistory Set(T_ArticleHistory dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
